#ifndef QMAINGUI_H
#define QMAINGUI_H


#include <QAction>
#include <QInputDialog>
#include <QFileDialog>
#include <QLabel>
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QPixmap>
#include <QScrollArea>
#include <QStatusBar>
#include <QtSvg>
#include <QTimer>
#include <QToolBar>

#include "cell.h"

#include "qmaincore.h"
#include "qmaincanvas.h"
#include "qmodelsaver.h"

//! A GUI implementation class.
/*!
  Responsible for menu, toolbars, status bars an so on.
  Allows user to start or stop calculation.
  Allows to reset default edges lengths.
  Switches modes for the QMainCanvas.
  */
class QMainGUI : public QMainWindow
{
    Q_OBJECT

private:
    QMainCanvas *canvas;
    QMainCore *core;

    //Requered actions
    QAction *newAction;
    QAction *openAction;
    QAction *saveAction;
    QAction *importAction;
    QAction *exportAction;
    QAction *toggleModelAction; //Run or Stop
    QAction *quitAction;

    QAction *cellModeAction;
    QAction *nodeModeAction;
    QAction *edgeModeAction;
    QAction *areaModeAction;

    QAction *resetDefaultLengthsAction;
    QAction *generateNodesAction;

    QAction *saveSvgAction;
    QAction *savePngAction;
    QAction *savePngsAction;

    QAction *showNodeNumberAction;
    QAction *showEdgeNumberAction;
    QAction *showAreaNumberAction;
    QAction *fieldModeAction;

    QAction *monitorAdhAction;
    QAction *monitorPolAction;
    QAction *monitorConAction;
    QAction *monitorElaAction;


    //Menus for the menu bar
    QMenu *fileMenu;
    QMenu *modeMenu;
    QMenu *editMenu;
    QMenu *toolMenu;
    QMenu *viewMenu;
    QMenu *monitorMenu;

    //Status Bar
    QLabel *modeLabel; //Cell, Node, Edge, Area
    QLabel *currentStateLabel; //Running or Stopped

    //GUI reqiurements
    QScrollArea *area;

    //Used for
    QTimer *recordTimer;
    unsigned long int recordedImagesCounter;

protected:
    void createActions(void);
    void createMenus(void);
    void createToolBars(void);
    void createStatusBar(void);

public:
    explicit QMainGUI(QMainCanvas *_canvas, QMainCore *_core, QWidget *parent = 0);
    ~QMainGUI();

signals:

private slots:
    //void on_<name>_triggered(void);

    void on_newAction_triggered(void);
    void on_openAction_triggered(void);
    void on_saveAction_triggered(void);

    void on_importAction_triggered(void);
    void on_exportAction_triggered(void);

    void on_toggleModelAction_triggered(void);

    void on_quitAction_triggered(void);

    void on_cellModeAction_triggered(void);
    void on_nodeModeAction_triggered(void);
    void on_edgeModeAction_triggered(void);
    void on_areaModeAction_triggered(void);

    void on_resetDefaultLengthsAction_triggered(void);

    void on_generateNodesAction_triggered(void);

    void on_saveSvgAction_triggered(void);
    void on_savePngAction_triggered(void);
    void on_savePngsAction_triggered(void);

    void on_showNodeNumberAction_triggered(bool showNodeNumber);
    void on_showEdgeNumberAction_triggered(bool showEdgeNumber);
    void on_showAreaNumberAction_triggered(bool showAreaNumber);

    void on_fieldModeAction_triggered(void);
    void toggleCanvasFieldMode(void);

    void on_monitorAdhAction_triggered(bool trackAdh);
    void on_monitorPolAction_triggered(bool trackPol);
    void on_monitorConAction_triggered(bool trackCon);
    void on_monitorElaAction_triggered(bool trackEla);

public slots:

    void externalToggleModelSlot(void);
    void savePngSlot(void);
};

#endif // QMAINGUI_H
